import request from 'utils/request';

export function getArticlesAPI(params) {
  return request({
    url: '/v1_0/mp/articles',
    params,
  });
}

//删除文章
export function delArticlesAPI(id) {
  return request({
    url: `/v1_0/mp/articles/${id}`,
    method: 'DELETE',
  });
}

//发布文章
export function publishArticlesAPI(data, draft = false) {
  return request({
    url: `/v1_0/mp/articles?draft=${draft}`,
    method: 'post',
    data,
  });
}

//获取文章详情
export function getArticlesDatailsAPI(id) {
  return request({
    url: `/v1_0/mp/articles/${id}`,
  });
}

//编辑文章详情
export function editArticlesDatailsAPI(id, data, draft = false) {
  return request({
    url: `/v1_0/mp/articles/${id}?draft=${draft}`,
    method: 'put',
    data,
  });
}
